package com.wesley.spring.proxy;

import com.wesley.spring.aop.advice.CustomBeforeAdvice;
import com.wesley.spring.proxy.biz.UserService;
import org.springframework.aop.framework.ProxyFactory;

/**
 * SpringProxyFactory
 *
 * @author WangPanYong
 * @since 2024/02/06
 */
public class SpringProxyFactory {
	public static void main(String[] args) {
		UserService userService = new UserService();
		ProxyFactory proxyFactory = new ProxyFactory();
		// 设置目标对象(被代理对象)
		proxyFactory.setTarget(userService);
		proxyFactory.addAdvice(new CustomBeforeAdvice());

		UserService proxy = (UserService)proxyFactory.getProxy();
		proxy.name();
	}
}
